package com.emmmya.ocs.modules.system.controller;

import com.emmmya.ocs.common.utils.DateUtils;
import com.emmmya.ocs.common.vo.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 创建人：咕噜肉IT小店-黑医
 * 创建时间 2022年10月11日 16:48:23
 * 描述：
 */
public class WelcomeController {
    /**
     * 欢迎页获取图表数据
     */
    @GetMapping("chartData")
    @ResponseBody
    @ApiOperation("欢迎页获取图表数据")
    public Result<Object> chartData(@RequestParam(value="typeNumber",required = false)Integer typeNumber){
        try {
            String today = DateUtils.getTodayDate();
            String otherDay4 = DateUtils.getOtherDay(today, -4);
//            switch (typeNumber){
//                //最近付款与未付款数据
//                case 1:
//                    ResultEntityVo vo = new ResultEntityVo();
//                    vo.setStart(otherDay4);
//                    vo.setEnd(today);
//                    vo.setTradeStatus(Drt66Constant.SUCCESS);
//                    List<ResultEntity> success = resultEntityService.selectList(vo.totalByDayWrapper());
//                    Map<String, String> collect1 = success.stream().collect(Collectors.toMap(e -> DateUtils.formatDate(e.getCreateTime(),"yyyy年MM月dd日"), e -> e.getSumMoney()));
//                    vo.setTradeStatus(Drt66Constant.UNPAID);
//                    List<ResultEntity> unpaid = resultEntityService.selectList(vo.totalByDayWrapper());
//                    Map<String, String> collect2 = unpaid.stream().collect(Collectors.toMap(e -> DateUtils.formatDate(e.getCreateTime(),"yyyy年MM月dd日"), e -> e.getSumMoney()));
//                    HashMap<String, Map<String, String>> result = new HashMap<>();
//                    result.put("success",collect1);
//                    result.put("unpaid",collect2);
//                    return ResultUtils.data(result);
//                case 2:
//                    ResultEntityVo vo2 = new ResultEntityVo();
//                    vo2.setTradeStatus(Drt66Constant.SUCCESS);
//                    ResultEntity totalSuccess = resultEntityService.getResult(vo2.totalWrapper());
//                    vo2.setTradeStatus(Drt66Constant.UNPAID);
//                    ResultEntity totalUnpaid = resultEntityService.getResult(vo2.totalWrapper());
//                    HashMap<String, String> result2 = new HashMap<>();
//                    result2.put("success",totalSuccess.getSumMoney());
//                    result2.put("unpaid", totalUnpaid.getSumMoney());
//                    return ResultUtils.data(result2);
//            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
